﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AG.Editor.Core;

namespace AG.Editor.UI
{
    public partial class AGPublishResourceWindow : Form
    {
        public AGPublishResourceWindow()
        {
            InitializeComponent();

            _ctlEditProjectName.Text = AGEContext.Current.EProject.Name;
            _ctlEditPublishPath.Text = "c:\\ag-publish\\";
        }

        private void _ctlBtnBrowse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _ctlEditPublishPath.Text = dlg.SelectedPath;
            }
        }

        private void _ctlBtnPublish_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_ctlEditPublishPath.Text))
            {
                return;
            }

            if (MessageBox.Show("确认发布?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            AGTools.Current.Publisher.PublishProject(_ctlEditPublishPath.Text, AGEContext.Current.EProject);
            MessageBox.Show("发布成功");
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}
